﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="add.aspx.cs" Inherits="StoreWeb.system.order.add" EnableEventValidation="false" %>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../../lib/html5.js"></script>
<script type="text/javascript" src="../../lib/respond.min.js"></script>
<script type="text/javascript" src="../../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <link href="../../css/album.css" rel="stylesheet" />
    <link href="../../css/menu.css" rel="stylesheet" />
    <link href="../../css/jquery.autocomplete.css" rel="stylesheet" />
    <link href="../../css/order.css" rel="stylesheet" />
    <script type="text/javascript" src="../../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../../lib/layer/1.9.3/layer.js"></script>
    <link href="../../lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <style type="text/css">
        body,
        .searchContainer,
        .mainContainer,
        .orderInfo {
            width: 100%;
            min-width: 1280px;
        }

            .searchContainer,
            .searchContainer ul,
            .searchContainer li {
                width: 100%;
            }

        .searchContainer {
            position: relative;
            padding-top: 5px;
        }

            .searchContainer li {
                height: 25px;
                line-height: 25px;
                display: none;
            }

                .searchContainer li .title,
                .searchContainer li .list,
                .searchContainer li .list a {
                    float: left;
                    display: inline;
                }

                    .searchContainer li .title,
                    .searchContainer li .list a {
                        margin-left: 10px;
                    }

                .searchContainer li .list {
                    width: 400px;
                }

                    .searchContainer li .list a {
                        margin-bottom: 10px;
                        height: 25px;
                        line-height: 25px;
                        padding: 0 10px;
                        border: 1px solid #c9c9c9;
                    }

                        .searchContainer li .list a:hover,
                        .searchContainer li .list a.active {
                            color: #333;
                            border: 1px solid #ff4400;
                            text-decoration: none;
                        }

            .searchContainer .arrow {
                position: absolute;
                top: 5px;
                right: 5px;
                display: block;
                width: 30px;
                height: 30px;
                background: url(../../images/arrow-bottom.jpg) center no-repeat;
            }

                .searchContainer .arrow.top {
                    background: url(../../images/arrow-top.jpg) center no-repeat;
                }

            .searchContainer .clear {
                clear: both;
            }

        .leftContainer div.listContainer,
        .leftContainer ul.image {
            float: left;
            overflow-x: hidden;
            overflow-y: auto;
        }

        .leftContainer div.listContainer {
            width: 130px;
            border-right: 1px solid #eee;
        }

        .leftContainer ul.list li {
            float: left;
            width: 100%;
            height: 28px;
            line-height: 28px;
            font-size: 14px;
            text-indent: 10px;
            cursor: pointer;
        }

            .leftContainer ul.list li.active {
                background: #eee;
            }

        .leftContainer ul.image {
            width: 260px;
            padding: 0 3px 0 5px;
        }

            .leftContainer ul.image li,
            .leftContainer ul.image li img {
                float: left;
            }

            .leftContainer ul.image li {
                width: 68px;
                height: 104px;
                overflow: hidden;
                margin: 5px 5px 0 5px;
                cursor: pointer;
            }

                .leftContainer ul.image li .image {
                    border: 1px solid #fff;
                }

                .leftContainer ul.image li.active .image {
                    border: 1px solid #ff4400;
                }

                .leftContainer ul.image li .image,
                .leftContainer ul.image li .image img {
                    width: 66px;
                    height: 66px;
                }

                .leftContainer ul.image li .text {
                    width: 68px;
                    height: 36px;
                    overflow: hidden;
                    line-height: 18px;
                    font-size: 14px;
                }

        .overflowdiv {
            overflow-x: hidden;
            overflow-y: auto;
        }

        .displaynone {
            display: none;
        }

        .displayblock {
            display: block;
        }
    </style>
    <title>添加订单</title>
</head>
<body>
    <div class="pd-20">
        <form id="formmemberadd" runat="server" class="form form-horizontal">
            <div>
                <div class="searchContainer">
                    <ul>
                        <li>
                            <div class="list">
                                <asp:Repeater ID="rpttype" runat="server">
                                    <ItemTemplate>
                                        <a href="###" onclick="gettype('<%#Eval("cinvCCode") %>','<%#Eval("cInvCName") %>','<%#Eval("iinvcgrade") %>','<%#Eval("bInvCEnd") %>')"><%#Eval("cInvCName") %></a>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                            <div class="clear"></div>
                        </li>
                        <li>
                            <div class="list" id="list2"></div>
                            <div class="clear"></div>
                        </li>
                        <li>
                            <div class="list" id="list3"></div>
                            <div class="clear"></div>
                        </li>
                    </ul>
                    <div class="clear"></div>
                    <a class="arrow" href="javascript:"></a>
                </div>

                <div class="mainContainer" style="border-top: 1px solid #ccc; overflow: hidden;">
                    <div class="leftContainer" style="width: 400px; float: left; margin: 5px 5px;">
                        <ul class="accordion">
                            <li id="one" class="files"><a href="#one">款式选择<span></span></a>
                                <div class="sub-menu">
                                    <div class="content-menu">
                                        <div class="listContainer">
                                            <div id="partsgroup">
                                            </div>
                                            <ul class="list" id="parts">
                                            </ul>
                                        </div>
                                        <div id="style" class="imageContainer">
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li id="two" class="mail"><a href="#two">面料选择<span></span></a>
                                <div class="sub-menu">
                                    <div class="content-menu">
                                        <div class="listContainer">
                                            <ul class="list" id="Inventory">
                                            </ul>
                                        </div>
                                        <div class="mianliao imageContainer">
                                            <input type="text" class="input-text" style="width: 200px; height: 28px; margin-left: 5px;" placeholder="根据规格型号" id="mlcode" name="mlcode">

                                            <ul id="mianliao">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li id="three" class="cloud"><a href="#three">尺寸选择<span></span></a>
                                <div class="sub-menu">
                                    <div class="content-menu">

                                        <div>
                                            <span id="sizestd1"></span>
                                            <span id="size1"></span>
                                        </div>
                                        <div>
                                            <span id="sizestd2"></span>
                                            <span id="size2"></span>
                                        </div>
                                        <div id="tetisize1" style="margin-top: 20px;">
                                        </div>
                                        <div id="tetisize2" style="margin-top: 20px;">
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li id="four" class="sign"><a href="#four">增值信息<span></span></a>
                                <div class="sub-menu">
                                    <div class="content-menu">
                                        <div id="value1">
                                        </div>
                                        <div id="valuekx1">
                                        </div>
                                        <div id="value2">
                                        </div>
                                        <div id="valuekx2">
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="albums" style="border-top: none; border-bottom: none;">
                        <div class="view">
                            <ul id="viewlist">
                            </ul>
                            <a href="javascript:" class="prev scroll"></a><a href="javascript:" class="next scroll"></a>
                        </div>
                    </div>
                    <div style="width: 300px; height: 100%; float: left; display: inline; margin-left: 10px;">
                        <div style="margin: 5px;">
                            <div id="styledetail"></div>
                            <div id="Inventorydetail"></div>
                        </div>
                    </div>
                </div>
                <div class="orderInfo" style="clear: both; border-top: 1px solid #ccc;">
                    <table style="line-height: 28px;">
                        <tr>
                            <td>订单属性：<span class="select-box inline" style="border: 0px;"><asp:RadioButtonList ID="rdobtntypelist" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="1" Selected="True">正常</asp:ListItem>
                                <asp:ListItem Value="2">重做</asp:ListItem>
                                <asp:ListItem Value="3">赠送</asp:ListItem>
                            </asp:RadioButtonList></span></td>
                            <td colspan="3">
                                <div id="isoriginalorder" style="display: none;">原订单号：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="originalordercode" name="originalordercode" runat="server"></div>
                            </td>


                        </tr>
                        <tr>
                            <td>定制日期：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtcreatetime" name="txtcreatetime" runat="server"></td>
                            <td>预计交期：<input type="text" class="input-text Wdate ui_input_txt02" onfocus="WdatePicker({maxDate:'#F{\'2020-10-01\'}'})" style="width: 170px; height: 25px;" id="txtendtime" name="txtendtime" runat="server"></td>

                            <td>快递：<asp:DropDownList ID="ddlistkuaidi" runat="server" RepeatDirection="Horizontal">
                            </asp:DropDownList></td>
                            <td>来源：<asp:DropDownList ID="ddlistlaiyuan" runat="server" RepeatDirection="Horizontal">
                            </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td>客户手机：<input type="text" class="input-text" style="width: 100px; height: 25px;" id="txtphone" name="txtphone" runat="server"><input type="button" style="width: 65px; height: 25px; margin-left: 5px; font-size: 14px; padding: 0px;" onclick="getphonecode(this)" class="btn btn-default" id="getcode" value="获取信息" /></td>
                            <td>客户姓名：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtname" name="txtname" runat="server"></td>

                            <td>地址：
                                <select name="typelist" id="s_province" runat="server"></select>


                                <select name="parentlist" id="s_city" runat="server"></select>


                                <select name="parentlist" id="s_county" runat="server"></select>

                                <input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtaddress" name="txtaddress" runat="server"></td>
                            <td>标签：<asp:DropDownList ID="ddlistbiaoqian" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="1">自己</asp:ListItem>
                                <asp:ListItem Value="2">朋友</asp:ListItem>
                                <asp:ListItem Value="3">亲戚</asp:ListItem>
                                <asp:ListItem Value="4">伴郎</asp:ListItem>
                            </asp:DropDownList>
                                <input type="text" class="input-text" style="width: 138px; height: 25px; display: none" id="biaoqian" name="biaoqian" runat="server">
                            </td>
                        </tr>

                        <tr>
                            <td>客户邮箱：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtemail" name="txtemail" runat="server"></td>
                            <td>客户性别：<span class="select-box inline" style="border: 0px;"><asp:RadioButtonList ID="ddlistsex" runat="server" RepeatDirection="Horizontal">
                                <asp:ListItem Value="0">保密</asp:ListItem>
                                <asp:ListItem Value="1" Selected="True">男</asp:ListItem>
                                <asp:ListItem Value="2">女</asp:ListItem>
                            </asp:RadioButtonList></span></td>

                            <td>生日：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtbothday" name="txtbothday" runat="server"></td>
                            <td>星座：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtconstellation" name="txtconstellation" runat="server"></td>
                        </tr>
                        <tr>
                            <td>身高(cm)：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtheight" name="txtheight" runat="server"></td>
                            <td>体重(kg)：<input type="text" class="input-text" style="width: 170px; height: 25px;" id="txtweight" name="txtweight" runat="server"></td>
                            <td colspan="2">体型：<span class="select-box inline" style="border: 0px;"><asp:CheckBoxList ID="cklisttixing" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList></span></td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <div class="row cl" style="margin-bottom: 5px;">
                                    <div class="formControls col-12">
                                        <div class="uploader-list-container">
                                            <div class="queueList">
                                                <div id="dndArea" class="placeholder" style="min-height: 0px;">
                                                    <div id="filePicker-2"></div>
                                                    <p>或将图片附件拖到这里,可上传多张</p>
                                                </div>
                                            </div>
                                            <div class="statusBar" style="display: none;">
                                                <div class="progress"><span class="text">0%</span> <span class="percentage"></span></div>
                                                <div class="info"></div>
                                                <div class="btns">
                                                    <div id="filePicker2"></div>
                                                    <div class="uploadBtn">开始上传</div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </td>

                        </tr>
                        <tr>
                            <td colspan="4">
                                <textarea id="txtnote" cols="100" rows="2" runat="server" style="height: 100px;" class="input-text" placeholder="请输入备注信息(非必填)"></textarea></td>
                        </tr>
                    </table>

                </div>
                <div style="height: 30px; margin-bottom: 10px; border-top: 1px solid #ccc;">
                    <table style="margin-top: 5px; left: 10px; width: 600px">
                        <tr>
                            <td>
                                <table id="rbtnpaytype">
                                    <tr>
                                        <td>应付款：</td>
                                        <td id="priceall">0.00</td>
                                        <td>实际付款：</td>
                                        <td id="rightprice" style="font-size: 18px; color: red; text-align: left; width: 200px; font-weight: bold;">0.00</td>
                                        <td style="display: none">
                                            <asp:RadioButtonList ID="rdobtnpaytypelist" runat="server" RepeatDirection="Horizontal">
                                                <asp:ListItem Value="0">支付宝</asp:ListItem>
                                                <asp:ListItem Value="1">微信</asp:ListItem>
                                                <asp:ListItem Value="2">刷卡</asp:ListItem>
                                                <asp:ListItem Value="3" Selected="True">现金</asp:ListItem>
                                            </asp:RadioButtonList>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <%--<td>
                                <input name="code" type="text" id="code" class="input-text" style="width: 150px; height: 31px;" placeholder="请输入验证码" />
                            </td>--%>
                            <td>
                                <asp:Button ID="btnsubmit" runat="server" OnClientClick="return article_save_submit();" class="btn btn-primary radius" Text="提交订单" OnClick="btnsubmit_Click" />
                                <input type="button" id="btnsubmitloding" style="display: none" class="btn btn-default radius" value="提交中..." />
                                <button onclick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button></td>
                        </tr>
                    </table>
                </div>
            </div>
            <input type="hidden" id="hidnum" value="1" />
            <input type="hidden" id="hidslectccode" runat="server" />
            <input type="hidden" id="hidcInvCCode" runat="server" />
            <input type="hidden" id="hidcInvCName" runat="server" />
            <%--        <input type="hidden" id="hidstylecode" />
            <input type="hidden" id="hidstyleispricedingdan" />--%>
            <input type="hidden" id="hidstyleprice" value="0" runat="server" />

            <input type="hidden" id="hidInventorycode" runat="server" /><%--选择的面料CODE--%>
            <input type="hidden" id="hidInventoryname" runat="server" /><%--选择的面料NAME--%>
            <input type="hidden" id="hidInventoryprice" value="0" runat="server" />

            <input type="hidden" id="vipdiscount" runat="server" />
            <input type="hidden" id="hidsendcode" runat="server" /><%--验证码--%>


            <input type="hidden" id="hidstyle" runat="server" /><%--部位款式信息json--%>
            <input type="hidden" id="hidsize" runat="server" /><%--尺寸信息json--%>
            <input type="hidden" id="hidtetisize" runat="server" /><%--特体处理json--%>

            <input type="hidden" id="hidistz" runat="server" /><%--是否套装--%>
            <input type="hidden" id="hidcInvCNames" runat="server" /><%--套装名字 逗号隔开--%>



            <input type="hidden" id="hidvaluetype" runat="server" /><%--增值部分json 可选部分json--%>
            <%--  <input type="hidden" id="hidkxsizetype" runat="server" /><%--可选部分json--%>

            <input type="hidden" id="hidsizecode2" runat="server" /><%--尺寸编码--%>
            <input type="hidden" id="hidcinvstd2" runat="server" /><%--尺寸编码--%>

            <input type="hidden" id="hidcinvstd" runat="server" /><%--规格型号--%>


            <input type="hidden" id="hidorderprice" runat="server" /><%--订单金额--%>
            <input type="hidden" id="hidorderbackupprice" runat="server" /><%--订单金额--%>
            <input type="hidden" id="hidordercode" runat="server" /><%--订单编号--%>
            <input type="hidden" id="hidsizecode" runat="server" /><%--尺寸编码--%>
            <input type="hidden" id="hidurls" runat="server" /><%--附件图片--%>
            <input type="hidden" id="hidmlcode" runat="server" />
        </form>
    </div>
    <script type="text/javascript" src="../../lib/Validform/5.3.2/Validform.min.js"></script>
    <script type="text/javascript" src="../../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../js/H-ui.js"></script>
    <script type="text/javascript" src="../../js/H-ui.admin.js"></script>
    <script src="../../js/sl.js"></script>
    <script src="../../js/jquery.album.slide.js"></script>
    <script src="../../js/menu.js"></script>
    <script src="../../js/jquery.autocomplete.js"></script>
    <script src="../../js/area.js"></script>
    <script type="text/javascript" src="../../lib/webuploader/0.1.5/webuploader.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var picTimer = setInterval(function () {
                var documentWidth = document.documentElement.clientWidth;
                if (documentWidth <= 1280)
                    documentWidth = 1280;
                var documentHeight = document.documentElement.clientHeight;
                //$("ul.sf-menu").superMenu();
                var $searchContainer = $('.searchContainer');
                var $searchLi = $('li', $searchContainer);
                $.each($searchLi, function (index) {
                    var $this = $(this);
                    //设置筛选条件内容的宽度
                    $('.list', $this).width(documentWidth - 100);
                    if (index == 0)
                        $this.show();
                    else if (index > 0)
                        $this.addClass('not-main');
                });
                var searchContainerHeight = parseInt($searchContainer.height());
                var $notMainLi = $('li.not-main', $searchContainer);
                var $orderInfo = $('.orderInfo');
                var orderInfoHeight = parseInt($orderInfo.height());
                $('.arrow', $searchContainer).click(function () {
                    var $this = $(this);
                    if (!$this.hasClass('top')) {
                        $this.addClass('top');
                        $notMainLi.show();
                        /*						$orderInfo.height(orderInfoHeight - (parseInt($searchContainer.height()) 
                                                    - searchContainerHeight));*/
                    } else {
                        $this.removeClass('top');
                        $notMainLi.hide();
                        /*						$orderInfo.height(orderInfoHeight);	*/
                    }
                });
                $('a', $('.list', $searchLi)).click(function () {
                    $(this).addClass('active').siblings('a').removeClass('active');
                });
                //$("#imgdocumentwidth").width(documentWidth - 750).height(height);
                var containerWidth = documentWidth - 400 - 300 - 55;
                //var containerHeight = documentHeight - searchContainerHeight - orderInfoHeight - 80; //中间容器高度
                var containerHeight = documentHeight - 75;
                $(".mainContainer").height(containerHeight + 20);
                var $li = $('.accordion > li');
                var liHeight = parseInt($('.accordion > li > a').height());
                var menuHeight = containerHeight - liHeight * ($li.length - 1) - 20;
                $(".content-menu", ".sub-menu").height(menuHeight);
                $("div.listContainer", ".sub-menu").height(menuHeight);
                $("div.imageContainer", ".sub-menu")
                    .height(menuHeight)
                    .css({ 'overflow-x': 'hidden', 'overflow-y': 'auto' });
                $(".view", ".albums").width(containerWidth).height(containerHeight);
                $("table", ".albums").width(containerWidth).height(containerHeight);
                $(".albums").width(containerWidth).height(containerHeight).albumSlide();
                clearInterval(picTimer);
            }, 100);
            $('.leftContainer ul.list').delegate('li', 'click', function () {
                $(this).addClass('active').siblings('li').removeClass('active');
            });
            $('.leftContainer ul.listx').delegate('li', 'click', function () {
                $(this).addClass('active').siblings('li').removeClass('active');
            });
            $('.sub-menu ul.image').delegate('li', 'click', function () {
                $(this).addClass('active').siblings('li').removeClass('active');
            });
            $('.searchContainer div.list').delegate('a', 'click', function () {
                $(this).addClass('active').siblings('a').removeClass('active');
            });
            $('.leftContainer ul.list li').click(function () {
                $(this).addClass('active').siblings('li').removeClass('active');
            }).first().addClass('active');
            $('.leftContainer ul.image li').click(function () {
                $(this).addClass('active').siblings('li').removeClass('active');
            }).first().addClass('active');
            //$.focus("#focus001");
            // Store variables
            var accordion_head = $('.accordion > li > a'),
                accordion_body = $('.accordion li > .sub-menu');
            // Open the first tab on load
            accordion_head.first().addClass('active').next().slideDown('normal');
            // Click function
            accordion_head.on('click', function (event) {
                // Disable header links
                event.preventDefault();
                // Show and hide the tabs on click
                if ($(this).attr('class') != 'active') {
                    accordion_body.slideUp('normal');
                    $(this).next().stop(true, true).slideToggle('normal');
                    accordion_head.removeClass('active');
                    $(this).addClass('active');
                }
            });
        });

        (function ($) {

            // 当domReady的时候开始初始化
            $(function () {
                var $wrap = $('.uploader-list-container'),

                    // 图片容器
                    $queue = $('<ul class="filelist"></ul>')
                        .appendTo($wrap.find('.queueList')),

                    // 状态栏，包括进度和控制按钮
                    $statusBar = $wrap.find('.statusBar'),

                    // 文件总体选择信息。
                    $info = $statusBar.find('.info'),

                    // 上传按钮
                    $upload = $wrap.find('.uploadBtn'),

                    // 没选择文件之前的内容。
                    $placeHolder = $wrap.find('.placeholder'),

                    $progress = $statusBar.find('.progress').hide(),

                    // 添加的文件数量
                    fileCount = 0,

                    // 添加的文件总大小
                    fileSize = 0,

                    // 优化retina, 在retina下这个值是2
                    ratio = window.devicePixelRatio || 1,

                    // 缩略图大小
                    thumbnailWidth = 110 * ratio,
                    thumbnailHeight = 110 * ratio,

                    // 可能有pedding, ready, uploading, confirm, done.
                    state = 'pedding',

                    // 所有文件的进度信息，key为file id
                    percentages = {},
                    // 判断浏览器是否支持图片的base64
                    isSupportBase64 = (function () {
                        var data = new Image();
                        var support = true;
                        data.onload = data.onerror = function () {
                            if (this.width != 1 || this.height != 1) {
                                support = false;
                            }
                        }
                        data.src = "";
                        return support;
                    })(),

                    // 检测是否已经安装flash，检测flash的版本
                    flashVersion = (function () {
                        var version;

                        try {
                            version = navigator.plugins['Shockwave Flash'];
                            version = version.description;
                        } catch (ex) {
                            try {
                                version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash')
                                        .GetVariable('$version');
                            } catch (ex2) {
                                version = '0.0';
                            }
                        }
                        version = version.match(/\d+/g);
                        return parseFloat(version[0] + '.' + version[1], 10);
                    })(),

                    supportTransition = (function () {
                        var s = document.createElement('p').style,
                            r = 'transition' in s ||
                                    'WebkitTransition' in s ||
                                    'MozTransition' in s ||
                                    'msTransition' in s ||
                                    'OTransition' in s;
                        s = null;
                        return r;
                    })(),

                    // WebUploader实例
                    uploader;

                if (!WebUploader.Uploader.support('flash') && WebUploader.browser.ie) {

                    // flash 安装了但是版本过低。
                    if (flashVersion) {
                        (function (container) {
                            window['expressinstallcallback'] = function (state) {
                                switch (state) {
                                    case 'Download.Cancelled':
                                        alert('您取消了更新！')
                                        break;

                                    case 'Download.Failed':
                                        alert('安装失败')
                                        break;

                                    default:
                                        alert('安装已成功，请刷新！');
                                        break;
                                }
                                delete window['expressinstallcallback'];
                            };

                            var swf = 'expressInstall.swf';
                            // insert flash object
                            var html = '<object type="application/' +
                                    'x-shockwave-flash" data="' + swf + '" ';

                            if (WebUploader.browser.ie) {
                                html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
                            }

                            html += 'width="100%" height="100%" style="outline:0">' +
                                '<param name="movie" value="' + swf + '" />' +
                                '<param name="wmode" value="transparent" />' +
                                '<param name="allowscriptaccess" value="always" />' +
                            '</object>';

                            container.html(html);

                        })($wrap);

                        // 压根就没有安转。
                    } else {
                        $wrap.html('<a href="http://www.adobe.com/go/getflashplayer" target="_blank" border="0"><img alt="get flash player" src="http://www.adobe.com/macromedia/style_guide/images/160x41_Get_Flash_Player.jpg" /></a>');
                    }

                    return;
                } else if (!WebUploader.Uploader.support()) {
                    alert('Web Uploader 不支持您的浏览器！');
                    return;
                }

                // 实例化
                uploader = WebUploader.create({
                    pick: {
                        id: '#filePicker-2',
                        label: '点击选择附件图片'
                    },
                    formData: {
                        uid: 123
                    },
                    dnd: '#dndArea',
                    paste: '#uploader',
                    swf: '../../lib/webuploader/0.1.5/Uploader.swf',
                    chunked: false,
                    chunkSize: 512 * 1024,
                    server: '../../lib/webuploader/0.1.5/server/Upload.aspx',
                    // runtimeOrder: 'flash',

                    // accept: {
                    //     title: 'Images',
                    //     extensions: 'gif,jpg,jpeg,bmp,png',
                    //     mimeTypes: 'image/*'
                    // },

                    // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候，把图片打开。
                    disableGlobalDnd: true,
                    fileNumLimit: 300,
                    fileSizeLimit: 200 * 1024 * 1024,    // 200 M
                    fileSingleSizeLimit: 50 * 1024 * 1024    // 50 M
                });

                // 拖拽时不接受 js, txt 文件。
                uploader.on('dndAccept', function (items) {
                    var denied = false,
                        len = items.length,
                        i = 0,
                        // 修改js类型
                        unAllowed = 'text/plain;application/javascript ';

                    for (; i < len; i++) {
                        // 如果在列表里面
                        if (~unAllowed.indexOf(items[i].type)) {
                            denied = true;
                            break;
                        }
                    }

                    return !denied;
                });

                uploader.on('dialogOpen', function () {
                    console.log('here');
                });

                // uploader.on('filesQueued', function() {
                //     uploader.sort(function( a, b ) {
                //         if ( a.name < b.name )
                //           return -1;
                //         if ( a.name > b.name )
                //           return 1;
                //         return 0;
                //     });
                // });

                // 添加“添加文件”的按钮，
                uploader.addButton({
                    id: '#filePicker2',
                    label: '继续添加'
                });

                uploader.on('ready', function () {
                    window.uploader = uploader;
                });

                // 当有文件添加进来时执行，负责view的创建
                function addFile(file) {
                    var $li = $('<li id="' + file.id + '">' +
                            '<p class="title">' + file.name + '</p>' +
                            '<p class="imgWrap"></p>' +
                            '<p class="progress"><span></span></p>' +
                            '</li>'),

                        $btns = $('<div class="file-panel">' +
                            '<span class="cancel">删除</span>' +
                            '<span class="rotateRight">向右旋转</span>' +
                            '<span class="rotateLeft">向左旋转</span></div>').appendTo($li),
                        $prgress = $li.find('p.progress span'),
                        $wrap = $li.find('p.imgWrap'),
                        $info = $('<p class="error"></p>'),

                        showError = function (code) {
                            switch (code) {
                                case 'exceed_size':
                                    text = '文件大小超出';
                                    break;

                                case 'interrupt':
                                    text = '上传暂停';
                                    break;

                                default:
                                    text = '上传失败，请重试';
                                    break;
                            }

                            $info.text(text).appendTo($li);
                        };

                    if (file.getStatus() === 'invalid') {
                        showError(file.statusText);
                    } else {
                        // @todo lazyload
                        $wrap.text('预览中');
                        uploader.makeThumb(file, function (error, src) {
                            var img;

                            if (error) {
                                $wrap.text('不能预览');
                                return;
                            }

                            if (isSupportBase64) {
                                img = $('<img src="' + src + '">');
                                $wrap.empty().append(img);
                            } else {
                                $.ajax('lib/webuploader/0.1.5/server/preview.php', {
                                    method: 'POST',
                                    data: src,
                                    dataType: 'json'
                                }).done(function (response) {
                                    if (response.result) {
                                        img = $('<img src="' + response.result + '">');
                                        $wrap.empty().append(img);
                                    } else {
                                        $wrap.text("预览出错");
                                    }
                                });
                            }
                        }, thumbnailWidth, thumbnailHeight);

                        percentages[file.id] = [file.size, 0];
                        file.rotation = 0;
                    }

                    file.on('statuschange', function (cur, prev) {
                        if (prev === 'progress') {
                            $prgress.hide().width(0);
                        } else if (prev === 'queued') {
                            $li.off('mouseenter mouseleave');
                            $btns.remove();
                        }

                        // 成功
                        if (cur === 'error' || cur === 'invalid') {
                            console.log(file.statusText);
                            showError(file.statusText);
                            percentages[file.id][1] = 1;
                        } else if (cur === 'interrupt') {
                            showError('interrupt');
                        } else if (cur === 'queued') {
                            percentages[file.id][1] = 0;
                        } else if (cur === 'progress') {
                            $info.remove();
                            $prgress.css('display', 'block');
                        } else if (cur === 'complete') {
                            $li.append('<span class="success"></span>');
                        }
                        $li.removeClass('state-' + prev).addClass('state-' + cur);
                    });

                    $li.on('mouseenter', function () {
                        $btns.stop().animate({ height: 30 });
                    });

                    $li.on('mouseleave', function () {
                        $btns.stop().animate({ height: 0 });
                    });

                    $btns.on('click', 'span', function () {
                        var index = $(this).index(),
                            deg;

                        switch (index) {
                            case 0:
                                uploader.removeFile(file);
                                return;

                            case 1:
                                file.rotation += 90;
                                break;

                            case 2:
                                file.rotation -= 90;
                                break;
                        }

                        if (supportTransition) {
                            deg = 'rotate(' + file.rotation + 'deg)';
                            $wrap.css({
                                '-webkit-transform': deg,
                                '-mos-transform': deg,
                                '-o-transform': deg,
                                'transform': deg
                            });
                        } else {
                            $wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')');
                            // use jquery animate to rotation
                            // $({
                            //     rotation: rotation
                            // }).animate({
                            //     rotation: file.rotation
                            // }, {
                            //     easing: 'linear',
                            //     step: function( now ) {
                            //         now = now * Math.PI / 180;

                            //         var cos = Math.cos( now ),
                            //             sin = Math.sin( now );

                            //         $wrap.css( 'filter', "progid:DXImageTransform.Microsoft.Matrix(M11=" + cos + ",M12=" + (-sin) + ",M21=" + sin + ",M22=" + cos + ",SizingMethod='auto expand')");
                            //     }
                            // });
                        }


                    });

                    $li.appendTo($queue);
                }

                // 负责view的销毁
                function removeFile(file) {
                    var $li = $('#' + file.id);

                    delete percentages[file.id];
                    updateTotalProgress();
                    $li.off().find('.file-panel').off().end().remove();
                }

                function updateTotalProgress() {
                    var loaded = 0,
                        total = 0,
                        spans = $progress.children(),
                        percent;

                    $.each(percentages, function (k, v) {
                        total += v[0];
                        loaded += v[0] * v[1];
                    });

                    percent = total ? loaded / total : 0;


                    spans.eq(0).text(Math.round(percent * 100) + '%');
                    spans.eq(1).css('width', Math.round(percent * 100) + '%');
                    updateStatus();
                }

                function updateStatus() {
                    var text = '', stats;

                    if (state === 'ready') {
                        text = '选中' + fileCount + '张效果图，共' +
                                WebUploader.formatSize(fileSize) + '。';
                    } else if (state === 'confirm') {
                        stats = uploader.getStats();
                        if (stats.uploadFailNum) {
                            text = '已成功上传' + stats.successNum + '张效果图，' +
                                stats.uploadFailNum + '张效果图上传失败，<a class="retry" href="#">重新上传</a>失败效果图或<a class="ignore" href="#">忽略</a>'
                        }

                    } else {
                        stats = uploader.getStats();
                        text = '共' + fileCount + '张（' +
                                WebUploader.formatSize(fileSize) +
                                '），已上传' + stats.successNum + '张';

                        if (stats.uploadFailNum) {
                            text += '，失败' + stats.uploadFailNum + '张';
                        }
                    }

                    $info.html(text);
                }

                function setState(val) {
                    var file, stats;

                    if (val === state) {
                        return;
                    }

                    $upload.removeClass('state-' + state);
                    $upload.addClass('state-' + val);
                    state = val;

                    switch (state) {
                        case 'pedding':
                            $placeHolder.removeClass('element-invisible');
                            $queue.hide();
                            $statusBar.addClass('element-invisible');
                            uploader.refresh();
                            break;

                        case 'ready':
                            $placeHolder.addClass('element-invisible');
                            $('#filePicker2').removeClass('element-invisible');
                            $queue.show();
                            $statusBar.removeClass('element-invisible');
                            uploader.refresh();
                            break;

                        case 'uploading':
                            $('#filePicker2').addClass('element-invisible');
                            $progress.show();
                            $upload.text('暂停上传');
                            break;

                        case 'paused':
                            $progress.show();
                            $upload.text('继续上传');
                            break;

                        case 'confirm':
                            $progress.hide();
                            $('#filePicker2').removeClass('element-invisible');
                            $upload.text('开始上传');

                            stats = uploader.getStats();
                            if (stats.successNum && !stats.uploadFailNum) {
                                setState('finish');
                                return;
                            }
                            break;
                        case 'finish':
                            stats = uploader.getStats();
                            if (stats.successNum) {
                                alert('上传成功');
                            } else {
                                // 没有成功的图片，重设
                                state = 'done';
                                location.reload();
                            }
                            break;
                    }

                    updateStatus();
                }

                uploader.onUploadProgress = function (file, percentage) {
                    var $li = $('#' + file.id),
                        $percent = $li.find('.progress span');

                    $percent.css('width', percentage * 100 + '%');
                    percentages[file.id][1] = percentage;
                    updateTotalProgress();
                };

                uploader.onFileQueued = function (file) {
                    fileCount++;
                    fileSize += file.size;

                    if (fileCount === 1) {
                        $placeHolder.addClass('element-invisible');
                        $statusBar.show();
                    }

                    addFile(file);
                    setState('ready');
                    updateTotalProgress();
                };

                uploader.onFileDequeued = function (file) {
                    fileCount--;
                    fileSize -= file.size;

                    if (!fileCount) {
                        setState('pedding');
                    }

                    removeFile(file);
                    updateTotalProgress();

                };

                uploader.on('all', function (type) {
                    var stats;
                    switch (type) {
                        case 'uploadFinished':
                            setState('confirm');
                            break;

                        case 'startUpload':
                            setState('uploading');
                            break;

                        case 'stopUpload':
                            setState('paused');
                            break;

                    }
                });
                uploader.on('uploadAccept', function (file, response) {
                    if ($("#hidurls").val() == "") {
                        $("#hidurls").val(response);
                    } else {
                        $("#hidurls").val($("#hidurls").val() + "|" + response);
                    }
                });
                uploader.onError = function (code) {
                    alert('Eroor: ' + code);
                };

                $upload.on('click', function () {
                    if ($(this).hasClass('disabled')) {
                        return false;
                    }

                    if (state === 'ready') {
                        uploader.upload();
                    } else if (state === 'paused') {
                        uploader.upload();
                    } else if (state === 'uploading') {
                        uploader.stop();
                    }
                });

                $info.on('click', '.retry', function () {
                    uploader.retry();
                });

                $info.on('click', '.ignore', function () {
                    alert('todo');
                });

                $upload.addClass('state-' + state);
                updateTotalProgress();
            });

        })(jQuery);
    </script>
    <script>
        //获取分类信息
        function gettype(cinvCCode, cInvCName, iinvcgrade, bInvCEnd) {
            $("#hidslectccode").val(cinvCCode);
            $("#hidcInvCCode").val(cinvCCode);
            $("#hidcInvCName").val(cInvCName);
            //if (bInvCEnd&&cInvCName=="西服套装")
            //    getParts(cinvCCode,cInvCName,true);
            //else if(bInvCEnd)
            //判断是否是套装形式
            $.ajax({
                type: "POST",
                url: "../../ajax/order.aspx?action=getproductconnection&id=" + cinvCCode,
                success: function (data) {
                    if (JSON.parse(data).istz)//是套装情况
                        getParts(cinvCCode, cInvCName, true, JSON.parse(data).list);
                    else
                        getParts(cinvCCode, cInvCName, false, null);
                }
            });
            if (iinvcgrade == 1) {
                $("#list2").empty();
                $("#list3").empty();
            } else if (iinvcgrade == 2)
                $("#list3").empty();

            $.ajax({
                type: "POST",
                url: "../../ajax/inventoryclass.aspx?action=gettype&iinvcgrade=" + iinvcgrade + "&cinvCCode=" + cinvCCode,
                success: function (data) {
                    $.each(JSON.parse(data), function (i, item) {
                        $("#list" + (parseInt(iinvcgrade) + 1) + "").append("<a href=\"###\" onclick=\"gettype('" + item.cInvCCode + "','" + item.cInvCName + "'," + item.iInvCGrade + "," + item.bInvCEnd + ")\">" + item.cInvCName + "</a>");
                    });
                }
            });
            //$.ajax({
            //    type: "POST",
            //    url: "../../ajax/order.aspx?action=getInventoryClassJson&id=" + cinvCCode ,
            //    success: function (data) {
            //        alert(data);
            //        $("#hidcInvCCode").val(data);
            //        $("#mlcode").unautocomplete();
            //        $("#mlcode").autocomplete($("#hidcInvCCode").val(), {
            //            matchContains: true,
            //            formatItem: function (row, i, max) {
            //                if (row.code != undefined) {
            //                    return "<table ><tr><td align='left'>[" + row.code + "]</td><td align='left'>" + row.cinvstd + "</td></tr></table>";
            //                } else {
            //                    return "<table ><tr><td align='left'>没有找到相关数据！</td></tr></table>";
            //                }
            //            },
            //            formatMatch: function (row, i, max) {
            //                alert(row.code + row.name + row.cinvstd);
            //                return row.code + row.name + row.cinvstd;
            //            }
            //        }).result(function (event, data, formatted) {
            //            if (data.code != undefined) {
            //                $("#mlcode").val(data.cinvstd);
            //                Inventorydetail(data.code, data.name, data.price, 2)
            //            }
            //            else
            //                $("#mlcode").val("");
            //        });
            //    }
            //});
        }
        //获取部位信息istz是否套装
        function getParts(clnvCCode, cInvCName, istz, list) {
            emptyall();
            if (istz)//是套装
            {
                $("#hidistz").val("1");//设置是否是套装
                var table = $("<table style=\"margin:5px;\"><tr></tr></table>");

                $.each(list, function (i, item) {
                    $("<td></td>").html("<input type=\"button\" value=\"" + item.connectioncInvCName + "\" style=\" height: 25px;  font-size: 14px; padding: 0px;\" onclick=\"getPartsbyname('" + item.connectioncInvCName + "'," + (i + 1) + ")\" class=\"btn btn-default\" />")
                        .appendTo(table);
                    if (i == 0) {
                        getPartsbyname(item.connectioncInvCName, i + 1);//如是套装则初始化
                    }
                    //设置套装冗余
                    if ($("#hidcInvCNames").val() == "") {
                        $("#hidcInvCNames").val(item.connectioncInvCName);
                    }
                    else {
                        $("#hidcInvCNames").val($("#hidcInvCNames").val() + "," + item.connectioncInvCName);
                    }
                    getcinvstd(item.connectioncInvCName, i + 1);//初始化尺寸规格型号
                    getvaluetype(item.connectioncInvCName, i + 1);//初始化增值选项
                });
                getInventory(cInvCName);//初始化面料
                $("#partsgroup").empty().append(table);
            } else {
                $("#hidistz").val("0");//设置是否是套装
                $("#hidcInvCNames").val(cInvCName);//设置名称冗余
                getInventory(cInvCName);//初始化面料
                getcinvstd(cInvCName, 1);//初始化尺寸规格型号
                getvaluetype(cInvCName, 1);//初始化增值选项
                $("#hidnum").val(1);
                $("#partsgroup").empty();
                $.ajax({
                    type: "POST",
                    url: "../../ajax/order.aspx?action=getParts&id=" + clnvCCode,
                    success: function (data) {
                        $.each(JSON.parse(data), function (i, item) {
                            $("#parts").append("<li id='" + item.code + "'  data-num='1'>" + item.name + "</li>");
                        });
                    }
                });
            }
        }
        //根据名称获取部位信息
        function getPartsbyname(clnvCName, num) {
            $("#hidnum").val(num);
            $.ajax({
                type: "POST",
                url: "../../ajax/order.aspx?action=getPartsbyclnvCName&id=" + clnvCName,
                success: function (data) {
                    $("#parts").empty();
                    $.each(JSON.parse(data), function (i, item) {
                        $("#parts").append("<li id='" + item.code + "' data-num='" + num + "'>" + item.name + "</li>");
                    });
                }
            });
        }

        //获取款式信息
        function getStyle(partscode, num) {
            if ($("#style" + partscode + "").length < 1)//不存在才加载
            {
                $.ajax({
                    type: "POST",
                    url: "../../ajax/order.aspx?action=getStyle&id=" + partscode,
                    success: function (data) {
                        var ul = $("<ul></ul>").addClass("image displaynone").attr("id", "style" + partscode);
                        $.each(JSON.parse(data), function (i, item) {
                            $("<li><div class='image'><img src='" + item.bantuurl + "'/></div><div class='text'><span>" + item.cInvName + "</span></div></li>")
                                .data("item", {
                                    stylecode: item.code,
                                    styletype: item.dtype,
                                    price: item.price,
                                    ispricedingdan: item.ispricedingdan,
                                    partscode: item.partscode,
                                    partsname: item.partsname,
                                    cInvCode: item.cInvCode,
                                    cInvName: item.cInvName,
                                    urls: item.xiaoguourl,
                                    tzgroup: num
                                })
                                .appendTo(ul)
                        });
                        $("#style").append(ul);
                        $("#style" + partscode + "").addClass('displayblock').siblings('ul').removeClass('displayblock');
                    }
                });
            } else {
                $("#style" + partscode + "").addClass('displayblock').siblings('ul').removeClass('displayblock');
            }
        }
        //根据分类名称获取规格型号
        function getcinvstd(clnvCName, num) {
            $.ajax({
                type: "POST",
                url: "../../ajax/order.aspx?action=getxinghaobycinvcname&cinvcname=" + clnvCName,
                success: function (data) {
                    var $select = $("<select id='selectcinvstd" + num + "'></select>").off("change")
                            .on("change", function () {
                                getsize($(this).val(), clnvCName, num);
                                gettetisize($(this).val(), clnvCName, num);//初始化特体尺寸
                            });
                    $.each(JSON.parse(data), function (i, item) {
                        if (i == 0) {
                            getsize(item.cinvstd, clnvCName, num);//初始化尺寸
                            gettetisize(item.cinvstd, clnvCName, num);//初始化特体尺寸
                        }
                        $("<option value='" + item.cinvstd + "'>" + item.cinvstd + "</option>")
                            .appendTo($select);
                    });
                    $("#sizestd" + num).html($select);
                }
            });
        }
        //面料信息
        function getInventory(cinvcname) {
            $.ajax({
                type: "POST",
                url: "../../ajax/order.aspx?action=getInventory&cinvcname=" + cinvcname,
                success: function (data) {
                    var ul = $("#Inventory");
                    $.each(JSON.parse(data), function (i, item) {
                        $("<li></li>").attr("data-cinvcode", item.cInvCCode).attr("data-price", item.price).attr("data-cinvname", item.cInvCName).html(item.cInvCName).appendTo(ul);
                    });
                }
            });
        }
        //获取商品尺寸
        function getsize(cInvStd, cInvCName, num) {
            $.ajax({
                url: "../../ajax/product.aspx?cInvStd=" + cInvStd + "&action=getsizelist",
                dataType: "json",
                success: function (data) {
                    var container = $("#size" + num).empty();
                    if (data.sizelist.length) {
                        var select = $("<select id='productsize" + num + "'></select>").off("change").on("change", function () {
                            getsizelist(cInvStd, cInvCName, $(this).val(), num);
                        }).appendTo(container);
                        $.each(data.sizelist, function (n, item) {
                            $("<option></option>").attr("value", item.code).html(item.code).appendTo(select);
                        });
                        var table = $("<table></table>").attr("id", "tablesize" + num).appendTo(container);

                        $("<thead><tr></tr></thead>")
                        .append("<td>" + cInvCName + "尺寸</td>")
                            .append("<td>参考尺寸</td>")
                            .append("<td>成衣尺寸</td>")
                            .append("<td>备注</td>")
                            .appendTo(table);
                        $.each(data.list, function (n, item) {
                            var $table = $("<table style='width:70px;'></table>");
                            var $tr = $("<tr></tr>").appendTo($table);
                            var td1 = $("<td></td>")
                                .appendTo($tr);
                            $("<a></a>")
                                .addClass("shopcart-disc")
                                .off("click")
                                .on("click", function () {
                                    delnum(item.id, item.value, item.minpx);
                                })
                                .appendTo(td1);
                            var td2 = $("<td></td>")
                                .appendTo($tr);
                            $("<input style='WIDTH: 35px; HEIGHT: 15px'\">")
                                .addClass("inpcls2 ordersize")
                                .attr("id", "szvl" + item.id)
                                .attr("value", item.value)
                                .data("item", {
                                    sizeid: item.id,
                                    sizecode: item.code,
                                    sizename: item.name,
                                    backupsize: item.value
                                })
                                .off("blur")
                                .on("blur", function () {
                                    checksize(item.id, item.value, item.minpx, item.maxpx);
                                })
                                .appendTo(td2);
                            var td3 = $("<td></td>")
                                .appendTo($tr);
                            $("<a></a>")
                                .addClass("shopcart-add")
                                .off("click")
                                .on("click", function () {
                                    addnum(item.id, item.value, item.maxpx);
                                })
                                .appendTo(td3);
                            var tr = $("<tr></tr>")
                                 .append("<td>" + item.name + "</td>")
                                 .append("<td>" + item.value + "</td>")
                                .appendTo(table);
                            $("<td></td>")
                                .append($table)
                                .appendTo(tr);
                            $("<td><span id='szbz" + item.id + "'></span><span  id='szbzbackup" + item.id + "'>" + item.note + "</span></td>")
                                .appendTo(tr);
                        });
                    }
                    else
                        container.html("暂无尺寸信息");
                }
            });
        }
        //获取具体尺寸
        function getsizelist(cInvStd, cInvCName, size, num) {
            $.ajax({
                url: "../../ajax/product.aspx?cInvStd=" + cInvStd + "&size=" + size + "&action=getsizelist",
                dataType: "json",
                success: function (data) {
                    var container = $("#tablesize" + num).empty();
                    if (data.sizelist.length) {
                        var table = $("<table></table>").attr("id", "tablesize" + num).appendTo(container);

                        $("<thead><tr></tr></thead>")
                            .append("<td>" + cInvCName + "尺寸</td>")
                            .append("<td>参考尺寸</td>")
                            .append("<td>成衣尺寸</td>")
                            .append("<td>备注</td>")
                            .appendTo(table);
                        $.each(data.list, function (n, item) {
                            var $table = $("<table style='width:70px;'></table>");
                            var $tr = $("<tr></tr>").appendTo($table);
                            var td1 = $("<td></td>")
                                .appendTo($tr);
                            $("<a></a>")
                                .addClass("shopcart-disc")
                                .off("click")
                                .on("click", function () {
                                    delnum(item.id, item.value, item.minpx);
                                })
                                .appendTo(td1);
                            var td2 = $("<td></td>")
                                .appendTo($tr);
                            $("<input style='WIDTH: 35px; HEIGHT: 15px'\">")
                                .addClass("inpcls2 ordersize")
                                .attr("id", "szvl" + item.id)
                                .attr("value", item.value)
                                .data("item", {
                                    sizeid: item.id,
                                    sizecode: item.code,
                                    sizename: item.name,
                                    backupsize: item.value
                                })
                                .off("blur")
                                .on("blur", function () {
                                    checksize(item.id, item.value, item.minpx, item.maxpx);
                                })
                                .appendTo(td2);
                            var td3 = $("<td></td>")
                                .appendTo($tr);
                            $("<a></a>")
                                .addClass("shopcart-add")
                                .off("click")
                                .on("click", function () {
                                    addnum(item.id, item.value, item.maxpx);
                                })
                                .appendTo(td3);
                            var tr = $("<tr></tr>")
                                 .append("<td>" + item.name + "</td>")
                                 .append("<td>" + item.value + "</td>")
                                .appendTo(table);
                            $("<td></td>")
                                .append($table)
                                .appendTo(tr);
                            $("<td><span id='szbz" + item.id + "'></span><span  id='szbzbackup" + item.id + "'>" + item.note + "</span></td>")
                                .appendTo(tr);
                        });
                    }
                    else
                        container.html("暂无尺寸信息");
                }
            });
        }
        //获取特体尺寸
        function gettetisize(cInvStd, cInvCName, num) {
            $.ajax({
                url: "../../ajax/product.aspx?cInvStd=" + cInvStd + "&action=gettetisizegroupby",
                dataType: "json",
                success: function (data) {
                    var list = "<table id=\"tabletetisize" + num + "\"><thead><tr><td style=\"background:#cccccc\" colspan=\"4\">" + cInvCName + "特体处理</td></tr></thead><tbody>";
                    $.each(data, function (n, item) {
                        if (n % 4 == 0)
                            list += "<tr class=\"text-c\">";
                        if (n + 1 == data.length)
                            list += "<td style=\"text-align: left\" colspan=\"" + (4 - (n % 4)) + "\"><span>" + item.groupname + "</span>";
                        else
                            list += "<td style=\"text-align: left\"><span>" + item.groupname + "</span>";
                        list += "&nbsp;<select>";

                        for (var i = 0; i < item.codelist.length; i++) {
                            list += "<option value=\"" + item.codelist[i] + "\">" + item.codelist[i] + "</option>";
                        }
                        list += "</select>";
                        list += "</td>";
                        if ((n != 0 && n % 4 == 0) || n + 1 == data.length)
                            list += "</tr>";
                    });
                    list += "</tbody></table>"
                    $("#tetisize" + num + "").html(list);
                }
            });
        }
        //获取增值选项
        function getvaluetype(cInvcName, num) {
            $.ajax({
                url: "../../ajax/value.aspx?cInvcName=" + cInvcName + "&action=getvalue",
                dataType: "json",
                success: function (data) {
                    //通用
                    var list = "<table id=\"tablevalue" + num + "\"><thead><tr><td style=\"background:#cccccc\" colspan=\"4\">" + cInvcName + "通用增值</td></tr></thead><tbody>";
                    var sort = 4;
                    $.each(data.tongyong, function (n, item) {
                        if (sort == 4) {
                            sort = 1;
                            list += "<tr class=\"text-c\">";
                        } else
                            sort++;
                        if (n + 1 == data.tongyong.length)
                            list += "<td style=\"text-align: left\" colspan=\"" + (4 - (n % 4)) + "\"><span>" + item.tongyongname + "</span>";
                        else
                            list += "<td style=\"text-align: left\"><span>" + item.tongyongname + "</span>";
                        list += "<input type='hidden' name='select' value='" + item.select + "' /><input type='hidden' name='code' value='" + item.code + "' />";
                        //判断是否是文本1文本 2下拉
                        if (item.select == "1") {
                            list += "<input type='text' name='text' style='width:60px;'/>";
                        }
                        else {
                            list += "&nbsp;<select>";
                            for (var i = 0; i < item.tongyonglist.length; i++) {
                                list += "<option value=\"" + item.tongyonglist[i] + "\">" + item.tongyonglist[i] + "</option>";
                            }
                            list += "</select>";
                        }
                        list += "</td>";
                        if (sort == 4) {
                            list += "</tr>";
                        }
                    });
                    list += "</tbody></table>"
                    $("#value" + num + "").html(list);
                    //指定增值
                    var list2 = "<table id=\"tablevaluekx" + num + "\"><thead><tr><td style=\"background:#cccccc\" colspan=\"4\">" + cInvcName + "分类增值</td></tr></thead><tbody>";
                    sort = 4;
                    $.each(data.guanlian, function (n, item) {
                        if (sort == 4) {
                            sort = 1;
                            list2 += "<tr class=\"text-c\">";
                        } else
                            sort++;
                        if (n + 1 == data.guanlian.length)
                            list2 += "<td style=\"text-align: left\" colspan=\"" + (4 - (n % 4)) + "\"><span>" + item.tongyongname + "</span>";
                        else
                            list2 += "<td style=\"text-align: left\"><span>" + item.tongyongname + "</span>";
                        list2 += "<input type='hidden' name='select' value='" + item.select + "' /><input type='hidden' name='code' value='" + item.code + "' />";
                        //判断是否是文本1文本 2下拉
                        if (item.select == "1") {
                            list2 += "<input type='text' name='text' style='width:60px;'/>";
                        }
                        else {
                            list2 += "&nbsp;<select>";
                            for (var i = 0; i < item.tongyonglist.length; i++) {
                                list2 += "<option value=\"" + item.tongyonglist[i] + "\">" + item.tongyonglist[i] + "</option>";
                            }
                            list2 += "</select>";
                        }
                        list2 += "</td>";
                        if (sort == 4)
                            list2 += "</tr>";
                    });
                    list2 += "</tbody></table>"
                    $("#valuekx" + num + "").html(list2);
                }
            });
        }
        function delnum(id, value, minpx) {
            var vl = parseFloat($("#szvl" + id + "").val()) - 1;//当前数值-1
            if (Math.abs(vl - value) > parseFloat(minpx))
                alert("最小偏差不能大于" + minpx);
            else {
                $("#szbz" + id + "").html((vl - value).toFixed(2));
                $("#szvl" + id + "").val(vl);//设置当前
            }
        }
        function addnum(id, value, maxpx) {
            var vl = parseFloat($("#szvl" + id + "").val()) + 1;//当前数值+1
            if (vl - value > parseFloat(maxpx))
                alert("最大偏差不能大于" + maxpx);
            else {
                $("#szbz" + id + "").html((vl - value).toFixed(2));
                $("#szvl" + id + "").val(vl);//设置当前
            }
        }
        function checksize(id, value, minpx, maxpx) {
            var vl = parseFloat($("#szvl" + id + "").val());//当前数值
            if (Math.abs(vl - value) > parseFloat(minpx) || vl - value > parseFloat(maxpx)) {
                alert("最小偏差不能大于" + minpx + "且最大偏差不能大于" + maxpx);
                $("#szvl" + id + "").val(value);//设置当前
            }
            else {
                $("#szbz" + id + "").html((vl - value).toFixed(2));
            }
        }
        _init_area();//初始化三级地区选择菜单
        //清空所有
        function emptyall() {
            $("#Inventory").empty()
            $("#parts").empty();
            $("#style").empty();
            $("#sizestd1").empty();
            $("#sizestd2").empty();
            $("#size1").empty();
            $("#size2").empty();
            $("#tablesize1").empty();
            $("#tablesize2").empty();
            $("#tetisize1").empty();
            $("#tetisize2").empty();
            $("#value1").empty();
            $("#value2").empty();
            $("#valuekx1").empty();
            $("#valuekx2").empty();
            $("#hidInventoryprice").val("0");
            $("#hidstyleprice").val("0");
            $("#hidInventorycode").val("");
            $("#hidInventoryname").val("");
            $("#Inventorydetail").html("");
            $("#styledetail").html("");
            $("#hidsize").val("");
            $("#hidtetisize").val("");
            $("#hidvaluetype").val("");

            $("#hidstyle").val("");

            $("#hidorderprice").val("0");
            $("#hidorderbackupprice").val("0");
            $("#hidcInvCNames").val("");
            //$("#hidkxsizetype").val("");
        }
        //设置款式信息
        function setstyle(item) {
            $(".orderstyle").each(function () {
                if ($(this).data("item").partscode == item.partscode) {
                    if ($(this).data("item").ispricedingdan) {
                        $("#hidstyleprice").val(parseFloat($("#hidstyleprice").val()) - parseFloat($(this).data("item").price));
                    }
                    $(this).remove();//重新选择
                }
            });
            if (item.ispricedingdan == "1") {
                var div = $("<div></div>")
                    .addClass("orderstyle")
                    .data("item", item)
                    .html(item.cInvName + "&nbsp;&nbsp;￥" + item.price);
                $("#styledetail").append(div);
                $("#hidstyleprice").val(parseFloat($("#hidstyleprice").val()) + parseFloat(item.price));
            } else {
                var div = $("<div></div>")
                  .addClass("orderstyle")
                  .data("item", item)
                  .html(item.cInvName);
                $("#styledetail").append(div);
            }
            //$("#hidstylecode").val(code);
            //$("#hidstyleispricedingdan").val(ispricedingdan);

            setprice();//计算金额
        }
        //获取面料信息
        function Inventorydetail(cInvCode, cInvName, price, type, cinvstd) {
            $("#Inventorydetail").html(cInvName + "&nbsp;&nbsp;￥" + (price == "" ? 0 : price) + "&nbsp;&nbsp;" + cinvstd);
            //1 分类 2面料
            if (type == 2) {
                $("#hidInventorycode").val(cInvCode);
                $("#hidInventoryname").val(cInvName);
            }
            $("#hidInventoryprice").val(price == "" ? 0 : price);
            setprice();//计算金额
        }
        //计算金额
        function setprice() {
            var orderprice = 0;
            var price = parseFloat(($("#hidInventoryprice").val() == "" ? 0 : $("#hidInventoryprice").val())) + parseFloat($("#hidstyleprice").val());
            $("#priceall").html(price);//计算应付款
            if ($("#vipdiscount").val() != "") {
                orderprice = parseFloat(($("#hidInventoryprice").val() == "" ? 0 : $("#hidInventoryprice").val())) * parseFloat($("#vipdiscount").val()) / 10 + parseFloat($("#hidstyleprice").val());
                $("#rightprice").html(orderprice + "<span style='color:#333; font-size:14px;'>(" + $("#vipdiscount").val() + "折)</span>");//计算实际付款
            }
            else {
                orderprice = price;
                $("#rightprice").html(price);//计算应付款
            }
            $("#hidorderbackupprice").val(price);//保存应付款
            $("#hidorderprice").val(orderprice);//保存实付款
        }

        var InterValObj; //timer变量，控制时间
        var count = 60; //间隔函数，1秒执行
        var curCount;//当前剩余秒数
        //60秒可再次点击获取验证码
        function settime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj);//停止计时器
                $("#getcode").removeAttr("disabled");//启用按钮
                $("#getcode").val("获取验证码");
            }
            else {
                curCount--;
                $("#getcode").val("重发(" + curCount + ")");
            }
        }
        //获取短信验证码并验证会员信息
        function getphonecode() {
            if ($("#txtphone").val() == "") {
                alert("请输入手机号");
                return
            }
            else {
                setstoremsg($("#txtphone").val());
            }
        }
        //获取会员信息
        function setstoremsg(phone) {
            //初始化折扣
            $("#vipdiscount").val("");
            //curCount = count;
            ////设置button效果，开始计时
            //$("#getcode").attr("disabled", "true");
            //$("#getcode").val("重发(" + curCount + ")");
            //InterValObj = window.setInterval(settime, 1000); //启动计时器，1秒执行一次
            //根据商品id获取商品规格型号
            $.ajax({
                url: "../../ajax/order.aspx?mobile=" + phone + "&action=getphonecode",
                dataType: "json",
                success: function (data) {
                    //if(data.sizelist!=""&&data.sizelist!=null)
                    //{
                    //    $.each(data.sizelist, function (i, item) {
                    //        $("#szvl"+item.sizeid).val(item.value);
                    //    });
                    //}
                    //if(!data.issend)
                    //    alert("验证码发送失败！");
                    //会员信息
                    if (data.member != "" && data.member != null) {
                        $("#txtname").val(data.member.name);
                        //$("#s_province").val(data.member.s_province);
                        //change(1);
                        //$("#s_city").val(data.member.s_city);
                        //change(2);
                        //$("#s_county").val(data.member.s_county);
                        //$("#txtaddress").val(data.member.address);
                        $("#txtemail").val(data.member.emal);
                        $("#ddlistsex").val(data.member.sex);
                        $("#txtbothday").val(data.member.birthday);
                        $("#txtconstellation").val(data.member.constellation);
                        $("#txtheight").val(data.member.height);
                        $("#txtweight").val(data.member.weight);
                    }
                    //折扣信息
                    if (data.grade != "" && data.grade != null) {
                        $("#vipdiscount").val(data.grade.discountrate);
                    }
                    $("#hidsendcode").val(data.code);
                }
            });
        }
        //获取尺寸信息
        function sizedetail() {
            var json = [];
            var tetijson = [];
            //获取具体尺寸
            $("#tablesize1>tbody>tr").each(function () {
                var item = $(this).find("input").data("item");
                $.extend(item, { tzgroup: 1, ordercode: $("#hidordercode").val(), note: $("#szbz" + item.sizeid).html(), shetnote: $("#szbzbackup" + item.sizeid).html(), sizevalue: $(this).find("input").val(), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西服上衣" : $("#hidcInvCName").val()) });
                json.push(item);
            });
            //获取套装情况尺寸
            $("#tablesize2>tbody>tr").each(function () {
                var item = $(this).find("input").data("item");
                $.extend(item, { tzgroup: 2, ordercode: $("#hidordercode").val(), note: $("#szbz" + item.sizeid).html(), shetnote: $("#szbzbackup" + item.sizeid).html(), sizevalue: $(this).find("input").val(), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西裤" : $("#hidcInvCName").val()) });
                json.push(item);
            });
            $("#hidsize").val(JSON.stringify(json));//保存尺寸信息
            //获取特体信息
            $("#tabletetisize1>tbody tr td").each(function () {
                var teti = {};
                $.extend(teti, { tzgroup: 1, ordercode: $("#hidordercode").val(), groupname: $(this).find("span").html(), tetiid: $(this).find("select").val(), code: $(this).find("select").find("option:selected").text(), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西服上衣" : $("#hidcInvCName").val()) });
                tetijson.push(teti);
            });
            //获取套装特体信息
            $("#tabletetisize2>tbody tr td").each(function () {
                var teti = {};
                $.extend(teti, { tzgroup: 2, ordercode: $("#hidordercode").val(), groupname: $(this).find("span").html(), tetiid: $(this).find("select").val(), code: $(this).find("select").find("option:selected").text(), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西裤" : $("#hidcInvCName").val()) });
                tetijson.push(teti);
            });
            $("#hidtetisize").val(JSON.stringify(tetijson));//保存特体处理
        }
        //获取增值信息
        function getvaluedetail() {
            var json = [];
            //获取增值部分
            $("#tablevalue1>tbody tr td").each(function () {
                var bixuan = {};
                $.extend(bixuan, { tzgroup: 1, ordercode: $("#hidordercode").val(), type: 1, selecttype: $(this).find("input[name='select']").val(), name: $(this).find("span").html(), code: $(this).find("input[name='code']").val(), value: ($(this).find("input[name='select']").val() == "1" ? $(this).find("input[name='text']").val() : $(this).find("select").find("option:selected").text()), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西服上衣" : $("#hidcInvCName").val()) });
                json.push(bixuan);
            });
            //获取套装增值部分
            $("#tablevalue2>tbody tr td").each(function () {
                var bixuan = {};
                $.extend(bixuan, { tzgroup: 2, ordercode: $("#hidordercode").val(), type: 1, selecttype: $(this).find("input[name='select']").val(), name: $(this).find("span").html(), code: $(this).find("input[name='code']").val(), value: ($(this).find("input[name='select']").val() == "1" ? $(this).find("input[name='text']").val() : $(this).find("select").find("option:selected").text()), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西裤" : $("#hidcInvCName").val()) });
                json.push(bixuan);
            });
            //获取可选部分
            $("#tablevaluekx1>tbody tr td").each(function () {
                var kexuan = {};
                $.extend(kexuan, { tzgroup: 1, ordercode: $("#hidordercode").val(), type: 2, selecttype: $(this).find("input[name='select']").val(), name: $(this).find("span").html(), code: $(this).find("input[name='code']").val(), value: ($(this).find("input[name='select']").val() == "1" ? $(this).find("input[name='text']").val() : $(this).find("select").find("option:selected").text()), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西服上衣" : $("#hidcInvCName").val()) });
                json.push(kexuan);
            });
            //获取套装可选部分
            $("#tablevaluekx2>tbody tr td").each(function () {
                var kexuan = {};
                $.extend(kexuan, { tzgroup: 2, ordercode: $("#hidordercode").val(), type: 2, selecttype: $(this).find("input[name='select']").val(), name: $(this).find("span").html(), code: $(this).find("input[name='code']").val(), value: ($(this).find("input[name='select']").val() == "1" ? $(this).find("input[name='text']").val() : $(this).find("select").find("option:selected").text()), cInvCCode: $("#hidcInvCCode").val(), hidcInvCName: ($("#hidcInvCName").val() == "西服套装" ? "西裤" : $("#hidcInvCName").val()) });
                json.push(kexuan);
            });
            $("#hidvaluetype").val(JSON.stringify(json));
            //$("#hidkxsizetype").val(JSON.stringify(kxjson));
        }
        //获取部位款式信息
        function styledetail() {
            var json = [];
            $(".orderstyle").each(function () {
                var item = $(this).data("item");
                $.extend(item, { ordercode: $("#hidordercode").val() });
                json.push(item);
            });
            //alert(JSON.stringify(json));
            $("#hidstyle").val(JSON.stringify(json));
        }
        function article_save_submit() {
            var issubmit = true;
            $("#btnsubmit").hide();
            $("#btnsubmitloding").show();
            $.ajax({
                async: false,
                url: "../../ajax/order.aspx?mobile=" + $("#txtphone").val() + "&action=getphonecode",
                dataType: "json",
                success: function (data) {
                    if (data.member!=null&&data.member.name != "" && $("#txtname").val() != data.member.name) {
                        issubmit = false;
                    }
                }
            });
            styledetail();//获取部位款式信息
            sizedetail();//获取尺寸信息
            getvaluedetail();//获取增值信息

            $("#hidsizecode").val($("#productsize1").val());//获取尺寸编码
            $("#hidcinvstd").val($("#selectcinvstd1").val());//获取规格型号

            $("#hidsizecode2").val($("#productsize2").val());//获取套装尺寸编码
            $("#hidcinvstd2").val($("#selectcinvstd2").val());//获取套装规格型号
            //验证
            //if($("#hidsendcode").val()==""){
            //    parent.layer.msg("请先验证手机号是否存在");
            //    issubmit=false;
            //} 
            //else if($("#hidsendcode").val()!=$("#code").val()){
            //    parent.layer.msg("验证码输入错误");
            //    issubmit=false;
            //}
            var sizejson = JSON.parse($("#hidsize").val());
            if (sizejson.length == 0)
            {
                parent.layer.msg("未能获取尺寸信息");
                issubmit = false;
            }
            else if ($("#hidsizecode").val() == "") {
                parent.layer.msg("未能获取尺寸编码");
                issubmit = false;
            }
            else if ($("#hidcinvstd").val() == "") {
                parent.layer.msg("未能获取规格型号");
                issubmit = false;
            }
            else if (!issubmit) {
                parent.layer.msg("一个客户手机只能对应一个客户姓名");
                issubmit = false;
            }
            else if ($("#hidstyle").val() == "[]") {
                parent.layer.msg("请选择部位款式");
                issubmit = false;
            }
            else if ($("#hidInventorycode").val() == "") {
                parent.layer.msg("请选择面料");
                issubmit = false;
            }
                //else if($("#hidsize").val()=="[]"){
                //    parent.layer.msg("请选择尺寸");
                //    issubmit=false;
                //} 
            else if ($("#txtphone").val() == "") {
                parent.layer.msg("请输入客户手机");
                issubmit = false;
            } else if ($("#txtname").val() == "") {
                parent.layer.msg("请输入客户姓名");
                issubmit = false;
            } else if ($("#txtaddress").val() == "") {
                parent.layer.msg("请输入客户具体地址");
                issubmit = false;
            }
            if (issubmit) {
                $("#btnsubmit").hide();
                $("#btnsubmitloding").show();
                return true;
            } else {
                $("#btnsubmit").show();
                $("#btnsubmitloding").hide();
                return false;
            }
        }
        $(function () {
            //默认初始化门店地址
            $("#s_province").val('<%=dm.s_province%>');
            change(1);
            $("#s_city").val('<%=dm.s_city%>');
            change(2);
            $("#s_county").val('<%=dm.s_county%>');
            $("#txtaddress").val('<%=dm.description%>');

            //订单属性如非正常显示原订单号
            $("#rdobtntypelist").change(function () {
                if ($("input[name='rdobtntypelist']:checked").val() == "1")
                    $("#isoriginalorder").hide();
                else
                    $("#isoriginalorder").show();
            });
            //如果标签非自己显示标签信息
            $("#ddlistbiaoqian").change(function () {
                if ($(this).val() == "1")
                    $("#biaoqian").hide();
                else
                    $("#biaoqian").show();
            });
            ////初始化部位信息
            //getParts($("#typelist").val());
            ////选择分类更新部位信息
            //$("#typelist").change(function () {
            //    getParts($(this).val());
            //});
            //点击部位
            $("#parts").on('click', "li", (function () {
                //获取款式信息
                getStyle($(this).attr("id"), $(this).attr("data-num"));
            }));
            //点击款式
            $("#style").on('click', "li", (function () {
                setstyle($(this).data("item"));
                //根据商品id获取商品规格型号
                //$.ajax({
                //    url: "../../ajax/inventory.aspx?cInvCode=" + $(this).data("item").cInvCode + "&action=getmodel",
                //    dataType: "json",
                //    success: function (data) {
                //        getsize(data!=null?data.cInvStd:"",$("#hidnum").val());//获取尺寸
                //        gettetisize(data.cInvCode,$("#hidnum").val());//获取特体尺寸
                //        getvaluetype(data.cInvCCode,$("#hidnum").val());//获取增值选项
                //    }
                //}); 
                //初始化图片
                var urls = $(this).data("item").urls.split('|');
                var list = "";
                for (var i = 0 ; i < urls.length; i++) {
                    list += "<li>";
                    list += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
                    list += "<tr>";
                    list += "<td><a href=\"javascript:\">";
                    list += "<img data-src=\"" + urls[i] + "\"></a></td>";
                    list += "</tr>";
                    list += "</table>";
                    list += "</li>";
                }
                $("#viewlist").html(list);
                $(".albums").albumSlide();//初始化大图
            }));
            //点击面料
            $("#Inventory").on('click', "li", (function () {
                Inventorydetail($(this).attr("data-cInvCode"), $(this).attr("data-cInvName"), $(this).attr("data-price"), 1, "")
                $("#mianliao").empty();
                $("#hidslectccode").val($(this).attr("data-cInvCode"));
                autocomplete();
                $.ajax({
                    type: "POST",
                    url: "../../ajax/order.aspx?action=getmianliaocInvStd&cinvccode=" + $(this).attr("data-cInvCode"),
                    success: function (data) {
                        var $ul = $("#mianliao");
                        $.each(JSON.parse(data), function (i, item) {
                            $("<li><h3>" + item.cinvstd + "</h3></li>")
                                .off("click")
                                .on("click", function () {
                                    Inventorydetail(item.code, item.name, item.price, 2, item.cinvstd);
                                }).appendTo($ul);
                        });
                    }
                });
            }));
            function autocomplete() {
                $("#mlcode").autocomplete("../../ajax/order.aspx?action=getInventoryClassJson&id=" + $("#hidslectccode").val(), {
                    matchContains: true,
                    //需要把data转换成json数据格式
                    parse: function (data) {
                        return $.map(eval(data), function (row) {
                            return {
                                data: row,
                                value: row.name + "&nbsp;" + row.cinvstd,
                                result: row.name + "&nbsp;" + row.cinvstd
                            }
                        });
                    },
                    formatItem: function (row, i, total) {
                        return row.name + "&nbsp;" + row.cinvstd;
                    },
                    formatMatch: function (row, i, total) {
                        return row.name + "&nbsp;" + row.cinvstd;
                    },
                    formatResult: function (data, value) {
                        return row.name + "&nbsp;" + row.cinvstd;
                    }
                }).result(function (event, data, formatted) { //回调
                    if (data.code != undefined) {
                        $("#mlcode").val(data.cinvstd);
                        Inventorydetail(data.code, data.name, data.price, 2, data.cinvstd)
                    }
                    else
                        $("#mlcode").val("");
                });
            }
            //$("#mlcode").autocomplete("../../ajax/order.aspx?action=getInventoryClassJson&id=" + $("#hidcInvCCode").val(), {
            //    matchContains: true,
            //    parse: function (row, i, max) {
            //        if (row.code != undefined) {
            //            return "<table ><tr><td align='left'>[" + row.code + "]</td><td align='left'>" + row.cinvstd + "</td></tr></table>";
            //        } else {
            //            return "<table ><tr><td align='left'>没有找到相关数据！</td></tr></table>";
            //        }
            //    },
            //    formatMatch: function (row, i, max) {
            //        return row.code + row.name+row.cinvstd;
            //    }
            //}).result(function (event, data, formatted) {
            //    if (data.code != undefined) 
            //    {
            //        $("#mlcode").val(data.cinvstd);
            //        Inventorydetail(data.code,data.name,data.price,2)
            //    }
            //    else
            //        $("#mlcode").val("");
            //});
            //$("#formmemberadd").Validform({
            //    tiptype: 2,
            //    btnSubmit: "#btnok",
            //    //callback: function (form) {
            //    //    form[0].submit();
            //    //    var index = parent.layer.getFrameIndex(window.name);
            //    //    parent.$('.btn-refresh').click();
            //    //    parent.layer.close(index);
            //    //}
            //    //,
            //    beforeSubmit: function (curform) {
            //        $.post("../../ajax/order.aspx", { vtype: $("#ddlisttype").val(), code: $("#code").val(), parentlist: $("#parentlist").val(), value: $("#value").val(), name: $("#name").val(), note: $("#note").val(), id: $("#hidid").val() },
            //        function (data) {
            //            if (data == 1) {
            //                parent.layer.alert("添加成功", function () {
            //                    parent.location.reload();
            //                });
            //            } else if (data == 2) {
            //                parent.layer.alert("修改成功", function () {
            //                    parent.location.reload();
            //                });
            //            } else {
            //                parent.layer.msg("操作失败");
            //            }
            //        });
            //        return false;
            //    }
            //});
        });
    </script>
</body>
</html>
